package com.gitee.utils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * Servlet工具类
 *  
 * @author  赵炎
 * @version  [V1.00, 2019年1月24日]
 * @since V1.00
 */
public class ServletUtil
{
    /**
     * 获取全部Servlet请求属性
     * 
     * @return
     */
    public static ServletRequestAttributes getRequestAttributes()
    {
        RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
        return (ServletRequestAttributes)attributes;
    }
    
    /** 
     * 获取Request
     * @return
     */
    public static HttpServletRequest getRequest()
    {
        return getRequestAttributes().getRequest();
    }
    
    /** 
     * 获取response
     * @return
     */
    public static HttpServletResponse getResponse()
    {
        return getRequestAttributes().getResponse();
    }
}
